<center><h3 class="bold"><?php echo $pollQuestion['body'] ?></h3></center>

<?php if ($total > 0): ?>
    <div id="pie" class="chart" style="width: 300px"></div>
    <script>
        data = $.parseJSON('<?php echo json_encode($data) ?>');

        $.plot($("#pie"), data, {
            series: {
                pie: {
                    show: true,
                    radius: 1,
                    label: {
                        show: true,
                        radius: 3 / 4,
                        formatter: labelFormatter,
                        background: {
                            opacity: 0.5,
                            color: '#000'
                        }
                    }
                }
            },
            grid: {
                hoverable: true
            }
        });

        $('#pie').width('450px');

        function labelFormatter(label, series) {
            return "<div style='font-size:8pt; text-align:center; padding:2px; color:#000;'>" + label.substring(0, 3) + "<br/>" + Math.round(series.percent) + "%</div>";
        }
    </script>
<?php else: ?>
    <div>
        <center>
            <span>Энэ санал асуулгад санал өгөөгүй байна</span>
            <ol style="list-style-position: inside">
                <?php foreach ($data as $i): ?>
                    <li><?php echo $i['label'] ?></li>
                <?php endforeach; ?>
            </ol>
        </center>
    </div>
<?php endif; ?>
